package bb.lanxing.lib.devices.ble.device;

//import com.alipay.sdk.packet.d;
import bb.lanxing.lib.devices.api.SmartDevice;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleSensorDevice;
import bb.lanxing.lib.devices.ble.ble.characteristic.BodySensorLocation;
import bb.lanxing.lib.devices.ble.ble.characteristic.BodySensorLocationCharacteristics;
import bb.lanxing.lib.devices.ble.ble.characteristic.hr.HeartRateAlertCmdCharacteristics;
import bb.lanxing.lib.devices.ble.ble.interfaces.BodySensorLocationController;
import bb.lanxing.lib.devices.ble.ble.services.DisBleService;
import bb.lanxing.lib.devices.ble.ble.services.HeartRateAlertService;
import bb.lanxing.lib.devices.ble.ble.services.HeartRateService;
import bb.lanxing.lib.devices.ble.heartrate.HeartRateBeltController;
import java.nio.ByteBuffer;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: HeartRateDevice.kt */

public final class HeartRateDevice extends BaseBleSensorDevice implements HeartRateBeltController, BodySensorLocationController {
    private final DisBleService disService;
    private final HeartRateService hearRateService;
    private final HeartRateAlertService heartRateAlertService;

    public HeartRateDevice(SmartDevice device) {
        super(device);
        Intrinsics.checkNotNullParameter(device, "device");
        HeartRateDevice heartRateDevice = this;
        this.disService = new DisBleService(heartRateDevice);
        this.hearRateService = new HeartRateService(heartRateDevice);
        this.heartRateAlertService = new HeartRateAlertService(heartRateDevice);
    }

    public boolean isSupport() {
        return this.heartRateAlertService.isCaptured();
    }

    @Override
    public boolean setWarnHr(int i) {
        ByteBuffer allocate = ByteBuffer.allocate(5);
        byte b = (byte) i;
        allocate.put((byte) -78);
        allocate.put((byte) 5);
        allocate.put((byte) 9);
        allocate.put(b);
        allocate.put((byte) ((-64) + b));
        HeartRateAlertCmdCharacteristics cmdCharacteristics = this.heartRateAlertService.getCmdCharacteristics();
        if (cmdCharacteristics != null) {
            byte[] array = allocate.array();
            Intrinsics.checkNotNullExpressionValue(array, "buffer.array()");
            return cmdCharacteristics.write(array);
        }
        return false;
    }

    @Override
    public boolean closeWarnHr() {
        ByteBuffer allocate = ByteBuffer.allocate(4);
        allocate.put((byte) -78);
        allocate.put((byte) 4);
        allocate.put((byte) 11);
        allocate.put((byte) -63);
        HeartRateAlertCmdCharacteristics cmdCharacteristics = this.heartRateAlertService.getCmdCharacteristics();
        if (cmdCharacteristics != null) {
            byte[] array = allocate.array();
            Intrinsics.checkNotNullExpressionValue(array, "buffer.array()");
            return cmdCharacteristics.write(array);
        }
        return false;
    }

    @Override
    public void initWarnHr() {
        ByteBuffer allocate = ByteBuffer.allocate(4);
        allocate.put((byte) -78);
        allocate.put((byte) 4);
        allocate.put((byte) 10);
        allocate.put((byte) -64);
    }

    @Override
    public BodySensorLocation getBodySensorLocation() {
        BodySensorLocationCharacteristics bodySensorLocationCharacteristics = this.hearRateService.getBodySensorLocationCharacteristics();
        if (bodySensorLocationCharacteristics != null) {
            return bodySensorLocationCharacteristics.getBodySensorLocation();
        }
        return null;
    }
}
